$(document).ready(function () {
    var list = $('#List');
    $('.xh-datagrid-toolbar').parseToolbar();
    $('.xh-form').parseForm($('#bt_form_add, #bt_form_edit'));
    /*初始化列表*/
    list.initDataGrid(moduleUrl + 'Service/getClientExecutingAssists').setSelectThenEnable(['bt_list_del']);
    /** 列表 **/
    $('#bt_list_add').click(function () {
        $.overtFun.clickAddList(list);
    });
    $('#bt_list_del').click(function () {
        var ids = list.getDataGridSelectedFields('id');
        $.overtFun.clickDelList(ids, moduleUrl + 'Service/delInstruction');
    });
    /**搜索**/
    $('#bt_list_search').click(function () {
        var _search = {"keywords": $('#List_Search').getElementValue()};
        list.addDataGridParams(_search);
    });
    /** 表单 **/
    $('#bt_form_add').click(function () {
        $.overtFun.clickSubmitForm();
    });
    $('#bt_form_back').click(function () {
        $.overtFun.clickBackForm();
    });
    $('#bt_form_reset').click(function () {
        $.overtFun.clickResetForm();
    });

});

/**
 * 同意协助
 * @param id
 */
function agreeAssist(id) {
    var href = "/assistance/assist/detail?id=" + id;

    $.ajax({
        type: "GET",
        url: moduleUrl + 'Service/agreeAssistance?id=' + id,
        contentType: "application/json",
        dataType: "json",
        success: function (data, textStatus, xhr) {
            if (xhr.status === 200) {
                // location.reload();
                //进入协助
                window.top.xhTop.createNewTab('协助详情', href);
            } else {
                $.messager.show({
                    title: 'Error',
                    msg: data.msg
                });
            }
        }

    });
}
